var http = require('http');

// 1. 创建 Server
var server = http.createServer();

// 2. 监听 request 请求，设置请求处理函数
server.on('request', function(req, res){
    console.log('Getting a request, url is: ' + req.url);

    // Respone different content to different request
    var url = req.url;
    res.setHeader('Content-Type', 'text/plain; charset=utf-8')
    if (url == '/') {
        res.end('index page')
    } else if (url == '/login') {
        res.end('登录')
    } else {
        res.end('404 Not Found.')
    }

    
});

// 3. 绑定端口号，启动服务
server.listen(8080, function(){
    console.log('Server is ready, listening 8080');
});